/**
 * 
 */
package com.seguriapp.sync;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;

import com.seguriapp.communication.WebServiceConsumer;

/**
 * @author pjohnson
 * 
 */
public class TramiteFileTask extends AsyncTask<Object, String, String> {

	private Context mContext;
	private ProgressDialog mDialog;
	private String mGetPath;

	public TramiteFileTask(final Context context, final String getPath) {
		mContext = context;
		mGetPath = getPath;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.os.AsyncTask#onPreExecute()
	 */
	@Override
	protected void onPreExecute() {
		super.onPreExecute();
		mDialog = ProgressDialog.show(mContext, "Documento", "Generando Documento");
	}

	@Override
	protected String doInBackground(Object... arg0) {
		final WebServiceConsumer webServiceConsumer = WebServiceConsumer
				.getInstance(mContext);
		

		final String rpta = webServiceConsumer.getTramiteFile(mGetPath);
		
		return rpta;
	}

	@Override
	protected void onPostExecute(final String result) {
		mDialog.dismiss();
		Intent i = new Intent(Intent.ACTION_VIEW);
		i.setData(Uri.parse(result));
		mContext.startActivity(i);
	}
}
